package net.cyl.manager.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import net.cyl.manager.LinkGroupManager;
import net.cyl.mapper.LinkGroupMapper;
import net.cyl.model.LinkGroupDO;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.Wrapper;
import java.util.List;

@Component
public class LinkGroupManagerImpl implements LinkGroupManager {
    @Autowired
    private LinkGroupMapper linkGroupMapper;
    @Override
    public int add(LinkGroupDO linkGroupDO) {
        return linkGroupMapper.insert(linkGroupDO);
    }

    @Override
    public int delete(Long id, Long accountNo) {
        return linkGroupMapper.delete( new QueryWrapper<LinkGroupDO>().eq("id", id).eq("account_no", accountNo));
    }

    @Override
    public LinkGroupDO detail(Long groupId, Long accountNo) {
        return linkGroupMapper.selectOne( new QueryWrapper<LinkGroupDO>().eq("id", groupId).eq("account_no", accountNo));
    }

    @Override
    public List<LinkGroupDO> findUserAllLinkGroup(Long accountNo) {
        return linkGroupMapper.selectList( new QueryWrapper<LinkGroupDO>().eq("account_no", accountNo));
    }

    @Override
    public int updateByIdf(LinkGroupDO linkGroupDO) {
        return linkGroupMapper.update(linkGroupDO, new QueryWrapper<LinkGroupDO>().eq("id", linkGroupDO.getId()).eq("account_no", linkGroupDO.getAccountNo()));
    }


}
